package com.triones.api.controller.api;

import cn.hutool.core.convert.Convert;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.triones.api.entity.WordOrderDO;
import com.triones.api.entity.vo.CustomWordOrderVO;
import com.triones.api.service.WordOrderService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * api - 工单管理
 *
 * @Author: triones
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/wordOrder")
public class ApiWordOrderController extends BaseController {

    private final WordOrderService wordOrderService;

    /**
     * 工单新增
     */
    @PostMapping
    @RepeatSubmit
    public R<Void> addWordOrder(@Validated @RequestBody WordOrderDO dto) {
        return toAjax(wordOrderService.apiAddWordOrder(dto));
    }

    /**
     * 工单删除
     */
    @DeleteMapping("/{id}")
    @RepeatSubmit
    public R<Void> memberRemove(@PathVariable Long id) {
        return toAjax(wordOrderService.apiMemberRemove(id));
    }

    /**
     * 工单列表（分页）
     */
    @GetMapping(value = "/list")
    public TableDataInfo<CustomWordOrderVO> apiPageList(PageQuery pageQuery) {
        return wordOrderService.apiPageList(pageQuery);
    }

    /**
     * 工单详情
     */
    @GetMapping(value = "/{id}")
    public R<CustomWordOrderVO> getInfoById(@PathVariable Long id) {
        return R.ok(wordOrderService.getInfo(id));
    }
}
